<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户管理系统 - 个人信息</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入 Font Awesome -->
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet">
    <!-- 引入自定义样式 -->
    <link rel="stylesheet" href="css/style.css">
    <!-- toastify.js CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/toastify-js/1.12.0/toastify.css" rel="stylesheet">
    <!-- toastify.js JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/toastify-js/1.12.0/toastify.min.js"></script>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <!-- 侧边栏 -->
        <nav class="col-md-3 col-lg-2 d-md-block bg-light sidebar">
            <div class="position-sticky">
                <div class="sidebar-brand d-flex align-items-center px-3 py-3 border-bottom">
                    <i class="fas fa-user-cog fa-2x me-2 text-primary"></i>
                    <span class="fs-5 fw-bold">用户管理系统</span>
                </div>
                <ul class="nav flex-column pt-3">
                    <li class="nav-item pt-2">
                        <a class="nav-link" href="user.html" id="userManagementLink">
                            <i class="fas fa-users fa-fw me-2"></i>
                            用户管理
                        </a>
                    </li>
                    <li class="nav-item pt-2">
                        <a class="nav-link" href="#" id="departmentManagementLink">
                            <i class="fas fa-building fa-fw me-2"></i>
                            部门管理
                        </a>
                    </li>
                    <li class="nav-item pt-2">
                        <a class="nav-link" href="#" id="roleManagementLink">
                            <i class="fas fa-user-tag fa-fw me-2"></i>
                            角色管理
                        </a>
                    </li>
                    <li class="nav-item pt-2">
                        <a class="nav-link active" href="#" id="profileLink">
                            <i class="fas fa-user-circle fa-fw me-2"></i>
                            个人信息
                        </a>
                    </li>
                    <li class="nav-item pt-2">
                        <a class="nav-link" href="#" id="logoutLink" onclick="logout()">
                            <i class="fas fa-sign-out-alt fa-fw me-2"></i>
                            退出登录
                        </a>
                    </li>
                </ul>
            </div>
        </nav>

        <!-- 主内容区域 -->
        <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
            <!-- ========== 页头：标题 + 操作区 ========== -->
            <div class="row mb-4">
                <div class="col-12 d-flex justify-content-between align-items-center">
                    <div>
                        <h2 class="mb-0">
                            <i class="fas fa-user-circle text-primary me-2"></i>
                            个人信息
                        </h2>
                    </div>
                </div>
            </div>

            <!-- ========== 选项卡导航 ========== -->
            <ul class="nav nav-tabs mb-4" id="profileTab" role="tablist">
                <li class="nav-item" role="presentation">
                    <button class="nav-link active" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="true">
                        <i class="fas fa-user-edit me-1"></i> 基本信息
                    </button>
                </li>
                <li class="nav-item" role="presentation">
                    <button class="nav-link" id="password-tab" data-bs-toggle="tab" data-bs-target="#password" type="button" role="tab" aria-controls="password" aria-selected="false">
                        <i class="fas fa-key me-1"></i> 修改密码
                    </button>
                </li>
            </ul>

            <!-- ========== 选项卡内容 ========== -->
            <div class="tab-content" id="profileTabContent">
                <!-- ========== 个人信息卡片 ========== -->
                <div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
                    <div class="row justify-content-center">
                        <div class="col-md-8 col-lg-6">
                            <form id="profile-form" class="needs-validation" novalidate>
                                <div id="profile-alert"></div>
                                <!-- 添加头像预览和上传部分 -->
                                <div class="row mb-3">
                                    <label class="col-sm-3 col-form-label">头像</label>
                                    <div class="col-sm-9">
                                        <div class="d-flex align-items-center">
                                            <!-- 头像预览区域 -->
                                            <input type="hidden" id="avatar" name="avatar">
                                            <div class="position-relative">
                                                <img id="avatar-preview" src="https://img.cdn1.vip/i/69135163eedbd_1762873699.jpg"
                                                        class="img-thumbnail" width="200" height="200" alt="头像预览">
                                            </div>

                                            <!-- 上传按钮 -->
                                            <div class="ms-4">
                                                <input type="file" class="form-control d-none" id="upload"
                                                        accept="image/*" onchange="previewAvatar(event)">
                                                <button type="button" class="btn btn-outline-primary" onclick="document.getElementById('upload').click()">
                                                    <i class="fas fa-upload me-1"></i>选择图片
                                                </button>
                                                <div class="form-text">支持 JPG、PNG 格式，大小不超过 10MB</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="username" class="col-sm-3 col-form-label">账号</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="username" name="username" readonly>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="name" class="col-sm-3 col-form-label">用户名</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="name" name="name" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="phone" class="col-sm-3 col-form-label">手机号码</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="phone" name="phone" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="email" class="col-sm-3 col-form-label">邮箱</label>
                                    <div class="col-sm-9">
                                        <input type="email" class="form-control" id="email" name="email" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="dept" class="col-sm-3 col-form-label">部门</label>
                                    <div class="col-sm-9">
                                        <select id="dept" name="deptId" class="form-select" aria-label="select dept" required>
                                        </select>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="role" class="col-sm-3 col-form-label">角色</label>
                                    <div class="col-sm-9">
                                        <select id="role" name="roleId" class="form-select" aria-label="select role" required>
                                        </select>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <div class="col-sm-3"></div>
                                    <div class="col-sm-9">
                                        <button type="submit" class="btn btn-primary">保存信息</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        </div>
                </div>

                <!-- ========== 密码重置卡片 ========== -->
                <div class="tab-pane fade" id="password" role="tabpanel" aria-labelledby="password-tab">
                    <div class="row justify-content-center">
                        <div class="col-md-8 col-lg-6">
                            <form id="password-form" class="needs-validation" novalidate>
                                <div id="password-alert"></div>
                                <div class="row mb-3">
                                    <label for="oldPassword" class="col-sm-3 col-form-label">旧密码</label>
                                    <div class="col-sm-9">
                                        <input type="password" class="form-control" id="oldPassword" name="oldPassword" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="newPassword" class="col-sm-3 col-form-label">新密码</label>
                                    <div class="col-sm-9">
                                        <input type="password" class="form-control" id="newPassword" name="newPassword" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <label for="passwordRepeat" class="col-sm-3 col-form-label">确认新密码</label>
                                    <div class="col-sm-9">
                                        <input type="password" class="form-control" id="passwordRepeat" name="passwordRepeat" required>
                                    </div>
                                </div>
                                <div class="row mb-3">
                                    <div class="col-sm-3"></div>
                                    <div class="col-sm-9">
                                        <button type="submit" class="btn btn-primary">重置密码</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        </div>
                </div>
            </div>
        </main>
    </div>
</div>

<!-- 引入 Bootstrap JS（含 Popper）-->
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.7/js/bootstrap.bundle.min.js"></script>
<!-- 引入自定义脚本 -->
<script src="js/profile.js"></script>
</body>
</html>